/*
 *  Gas.h
 *  Copyright 2008 . All rights reserved.
 */

#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "Car.h"

@interface Gas : NSObject {
    sqlite3 *database;
    int pk;
	int car_fk;
	NSDate *date;
	float odometer;
	float volume;
	float cost;
	BOOL full;

    // Dirty tracks whether there are in-memory changes to data which have no been written to the database.
    BOOL dirty;
}

@property (nonatomic, assign) sqlite3 *database;
@property (nonatomic, assign) int pk;
@property (nonatomic, assign) int car_fk;
@property (nonatomic, assign) NSDate *date;
@property (nonatomic, assign) float odometer;
@property (nonatomic, assign) float volume;
@property (nonatomic, assign) float cost;
@property (nonatomic, assign) BOOL full;
@property (nonatomic, assign) BOOL dirty;

// Finalize (delete) all of the SQLite compiled queries.
+ (void)finalizeStatements;
// Get all entries for a car
+ (void)getAll:(NSMutableArray *)output car_id:(int)fk database:(sqlite3 *)db;

- (id)init:(Car *)car;
// Creates the object with primary key and title is brought into memory.
- (id)initWithPrimaryKey:(int)key car_id:(int)fk database:(sqlite3 *)db;
// Inserts the entry into the database and stores its primary key.
- (void)insertIntoDatabase:(sqlite3 *)database;
// save entry
- (void)updateDatabase;
// Remove the entry complete from the database. In memory deletion to follow...
- (void)deleteFromDatabase;
// Remove all entries for a car
+ (void)deleteForCar:(sqlite3 *)database car_id:(int)car_fk;

+ (int)exportHeaderLen;
+ (const char *)exportHeader;
- (const char *)exportCString:(NSDateFormatter *)dateFormatter;

@end
